package com.hjy.hjyojbackenduserservice.controller.inner;

import com.hjy.hjyojbackendjudgeservice.model.entity.User;
import com.hjy.hjyojbackendserviceclient.service.UserFerignClient;
import com.hjy.hjyojbackenduserservice.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * @version 1.0
 * @Author HJY_Maker
 * @Date 2024/7/5 星期五 13:27
 * 该服务仅内部调用，不是给前端的
 */
@RestController
@RequestMapping("/inner")
public class UserInnerController implements UserFerignClient {
    @Resource
    private UserService userService;

    /**
     * 获取用户信息
     *
     * @param userId
     * @return
     */
    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("userId") long userId) {
        return userService.getById(userId);
    }

    /**
     * 获取用户信息
     *
     * @param idList
     * @return
     */
    @Override
    @GetMapping("/get/ids")
    public List<User> listByIds(@RequestParam("idList") Collection<Long> idList) {
        return userService.listByIds(idList);
    }
}
